package xio.ccf_201412;

import java.util.*;

/**
 * 集合竞价 201412-3 100分
 * Created by xio on 2017/11/10 0010.
 */
public class CallAuction {
    public static void main(String[] args){
        Scanner sc =  new Scanner(System.in);
        String str ="";
        ArrayList<Trade> list = new ArrayList<>();
        while (sc.hasNextLine() ){
           str = sc.nextLine();
            if (str.trim().length() == 0) {
                break;
            }
           String[] arr = str.split(" ");
           if (arr.length <=0){
               continue;
           }
            switch (arr[0]) {
                case "buy":
                    list.add(new Trade(1, Double.parseDouble(arr[1]), Integer.parseInt(arr[2])));
                    break;
                case "sell":
                    list.add(new Trade(0, Double.parseDouble(arr[1]), Integer.parseInt(arr[2])));
                    break;
                case "cancel":
                    int id = Integer.parseInt(arr[1]) - 1;
                    list.get(id).count = 0; //撤销该行后不能remove,因为该行仍在list中占位，只能count置0
                    list.add(new Trade(2, 0, 0));//撤销也是一行操作，需要加入list
                    break;
            }
        }

        //按价格从小到大排序，价格相同的，sell在buy之前
        Collections.sort(list);
//        for (Trade trade : list) {
//            System.out.println(trade.toString());
//        }
        long trans = 0;
        long[] sellCount = new long[list.size()];
        long[] buyCount = new long[list.size()];

        //不同开盘价下对应的卖出总股数
        for (int i = 0; i < list.size(); i++) {
            Trade t = list.get(i);
            if (t.type == 0){
                trans+=t.count;
            }
            sellCount[i] = trans;
        }

        //不同开盘价下对应的买入总股数
        trans = 0;
        for (int i = list.size()-1; i >= 0; i--) {
            Trade t = list.get(i);
            if (t.type == 1){
                trans+=t.count;
            }
            buyCount[i] = trans;
        }

        double resultPrice =0;
        long resultCount = 0;
        for (int i = 0; i < list.size(); i++) {
           long c = Math.min(sellCount[i],buyCount[i]);
            if (c >= resultCount){
                resultCount = c;
                resultPrice = list.get(i).price;
            }
        }
        System.out.println(String.format("%.2f %d",resultPrice,resultCount));

    }

    static class Trade implements Comparable<Trade>{
        int type; // 0:sell; 1:buy; 2:cancel;
        double price;
        int count ;

        public Trade(int type, double price, int count) {
            this.type = type;
            this.price = price;
            this.count = count;
        }


        public int compareTo(Trade o) {
            if (this.price > o.price){
                return 1;
            }else if (this.price < o.price){
                return -1;
            }else {
                if (this.type > o.type){
                    return 1;
                }else if (this.type < o.type) {
                    return -1;
                }
                return 0;
            }
        }

        @Override
        public String toString() {
            return "Trade{" +
                    "type=" + type +
                    ", price=" + price +
                    ", count=" + count +
                    '}';
        }
    }
}
